﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;

using CanDoo.Core;
using CanDoo;
using CanDoo.Data;
using CanDoo.Web;

using CanDoo.Oil.Core.Models;
using CanDoo.Oil.Core.Contracts;
using FineUIPro;

namespace CanDoo.Oil.WebApp.sysDepartment
{
    public partial class Default : CanDoo.FineUI.TreeListPageBase<IDepartmentContract, Department>
    {

        #region PagePower

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string PageCode
        {
            get
            {
                return "sysdepartment";
            }
        }

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string ViewPower
        {
            get
            {
                return "sysdepartmentview";
            }
        }

        /// <summary>
        /// 本页面的功能模块
        /// </summary>
        public override string PageTitle
        {
            get
            {
                return "系统部门";
            }
        }

        #endregion
        
        #region Page_Load

        protected override void InitGrid()
        {
            Selector = p => new
            {
                p.Id,
                p.CreatedTime,
                p.Code,
                p.SortIndex,
                p.Remark,
                p.ParentId,
             //   ParentName = p.Parent.Name,
                p.Name,
                p.TreeLevel,
                p.IsTreeLeaf
            };

            GridList.DataSource = this.Manager.GetResolvedTree(Selector);
            GridList.DataBind();

            //base.InitGrid();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Manager.KeepReading(InitGrid);
                //InitGrid();
            }
        }
        #endregion

    }
}
